﻿@using FluentValidation
@using Masa.BuildingBlocks.StackSdks.Auth.Contracts.Model
@namespace Masa.Stack.Components.Layouts
@inherits MasaComponentBase

<SSimpleDialog @bind-Value="Value"
               HideCloseIcon=true
               Title="@T("UpdatePassword")"
               IconOfTitle="mdi-key-variant"
               OnCancel="HandleOnCancel"
               OnOk="HandleOnOk">
    <MForm Model="Model" EnableValidation @ref="_form">
        @if (HasOldPassword)
        {
            <STextField @bind-Value="Model.OldPassword"
                    Type="password"
                    Label="@T("OldPassword")"
                    HideDetails="false" />
        }
        <STextField @bind-Value="Model.NewPassword"
                    Type="password"
                    Label="@T("NewPassword")"
                    HideDetails="false" />
        <STextField @bind-Value="Model.ConfirmNewPassword"
                    Type="password"
                    Label="@T("ConfirmNewPassword")"
                    Placeholder="@T("PlaceholderForConfirmNewPassword")"
                    HideDetails="false" />
    </MForm>
    <a class="primary--text caption float-right"
       @onclick="() => _forgetPasswordModal.Open()">
        @T("ForgetPassword")
    </a>
</SSimpleDialog>

<CascadingValue Value="this">
    <ForgetPasswordModal @ref="_forgetPasswordModal" />
</CascadingValue>